<?php
			$obj=new mysql($config);
			if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_GET['flag']=='del'){
                       $id=$_GET['id'];
                       if(!empty($id)){
		                       $row=$obj->delete($id,'news');
		                       echo $row;
		                       die;	
                       }else{
		                       echo 0;
		                       die;
                       }
			
			}

			if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_GET['flag']=='look'){
				$id=$_GET['id'];
                for ($i=0; $i <count($id); $i++) { 
                	$row[$id[$i]]=$obj->update(array('statue'=>1),array('id'=>$id[$i],'statue'=>0),'news');
                }
                echo json_encode($row);
				die;

			}

			if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_GET['flag']=='addtr'){
                $sql="select * from `cate` where `pid`=0";
                $date=$obj->getCondition($sql);
                echo json_encode($date);
                die;
			}

			if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_GET['flag']=='cate'){
                $id=$_GET['id'];
                $sql="select * from `cate` where `pid`=$id";
                $date=$obj->getCondition($sql);
                echo json_encode($date);
                die;
			}

			if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_GET['flag']=='add'){
				$_POST['createtime']=time();
				$row=$obj->insert($_POST,'news');
				echo $row;
				die;
			}

			if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_GET['flag']=='catelist'){
                $id=$_GET['id'];

             
                function getC($id,$obj){	
                	static $arr=array();
	                $sql="select * from `cate` where id=$id";
	                $date=$obj->getOne($sql);
	                if($id!=0){
	                $sql2="select * from `cate` where pid=$date[pid]";
	                $arr[$id]=$obj->getCondition($sql2);
	                $arr=getC($date['pid'],$obj);  
	                }
	                return $arr;
                }

					echo json_encode(getC($id,$obj));  
				die;
			}

			if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_GET['flag']=='updatecid'){
                    $cid=$_GET['cid'];
                    $id=$_GET['id'];
                    $row=$obj->update(array('cid'=>$cid),array('id'=>$id),'news');
                    echo $row;
                    die;
			}